class PublicPopsicle < Popsicle
	belongs_to :entity, :foreign_key => 'public_author_id'
  belongs_to :created_location, :class_name => 'Entity', :foreign_key => 'created_location_id'
	named_scope :publicly_available, :include => :created_location, 
                                   :conditions => [ 'entities.introverted = ? OR 
                                                    popsicles.created_location_id = popsicles.public_author_id', false ]
  before_save :ensure_created_location_set
  attr_reader :created_location_entity
  
  def ensure_created_location_set #Created by Adrian
    return !self.created_location_id.nil?
  end
  
	def create_response(entity_id,content) #Created by Adrian
		PublicPopsicle.create(:public_author_id => entity_id, :subject => self.subject, :prev_popsicle => self.id, :content => content, :created_location_id => -1)
  end

  def available_for_feed #Created by Adrian
    return !created_location.introverted
  end
end
